<?php
/**
 * User: dimka3210
 * Date: 19.11.13
 * Time: 19:55
 */

class Storage
{
    private static $storage = array();

    /**
     * @return FileStorage|MysqlStorage
     */
    public static function getInstance()
    {
        $params = CNF::$params;
        if (isset(self::$storage[$params['storage']['type']])) {
            return self::$storage[$params['storage']['type']];
        }

        if ($params['storage']['type'] == 'mysql') {
            self::$storage[$params['storage']['type']] = new MysqlStorage($params['db']['host'], $params['db']['user'], $params['db']['pass']);
        } elseif ($params['storage']['type'] == 'file') {
            self::$storage[$params['storage']['type']] = new FileStorage();
        }

        return self::$storage[$params['storage']['type']];
    }
} 